-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expression: Fix some datetime related cases that is inconsistent with MySQL #7636
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
expression/builtin_cast.go
Outdated
@@ -1175,7 +1175,7 @@ func (b *builtinCastStringAsTimeSig) evalTime(row chunk.Row) (res types.Time, is | |||
sc := b.ctx.GetSessionVars().StmtCtx | |||
res, err = types.ParseTime(sc, val, b.tp.Tp, b.tp.Decimal) | |||
if err != nil { | |||
return res, false, errors.Trace(err) | |||
return res, false, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for removing the Trace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eurekaka nope. This should be change by mistake. I'll fix here.
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What problem does this PR solve?
This pr fixes some
datetime
related cases in TiDB that is inconsistent with MySQL.NO_ZERO_DATE
is not taken into consideration in some builtin-time functions(month
,dayofmonth
,year
,monthname
). In MySQL, ifNO_ZERO_DATE
is not set, no error or warning should happen on zero datetime such as0000-00-00 00:00:00
.For example, in MySQL:
While in TiDB:
float
values are not correctly cast intodatetime
.For example, in MySQL:
While in TiDB:
What is changed and how it works?
Changed the way some builtin_time functions deal with
ZERO
datetimeCheck List
Tests
Unit tests && integration tests